﻿/*
var banner = new FragmentBanner({
    container: "#banner1", //选择容器 必选
    imgs: ['/web/home/images/2.jpg'],
    size: {
        width: document.body.scrollWidth,
        height: (650/1920)*document.body.scrollWidth
    },
    grid: {
        line: 12,
        list: 14
    },
    index: 0, //图片集合的索引位置 可选
    type: 2, //切换类型 1 ， 2 可选
    boxTime: 2500, //小方块来回运动的时长 可选
    fnTime: 10000 //banner切换的时长 可选
});*/
function elementPosition(obj) {
    var curleft = 0, curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft;
        curtop = obj.offsetTop;
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        }
    }
    return { x: curleft, y: curtop };
}
function ScrollToControl(id)
{
    var elem = document.getElementById(id);
    var scrollPos = elementPosition(elem).y;
    scrollPos = scrollPos - document.documentElement.scrollTop;
    var remainder = scrollPos % 50;
    var repeatTimes = (scrollPos - remainder) / 50;
    ScrollSmoothly(scrollPos,repeatTimes);
    window.scrollBy(0,remainder);
}
var repeatCount = 0;
var cTimeout;
function ScrollSmoothly(scrollPos,repeatTimes)
{
    if(repeatCount < repeatTimes)
    {
        window.scrollBy(0,50);
    }
    else
    {
        repeatCount = 0;
        clearTimeout(cTimeout);
        return;
    }
    repeatCount++;
    cTimeout = setTimeout("ScrollSmoothly('"+scrollPos+"','"+repeatTimes+"')",10);
}